import request from '@/utils/request'

export function search(inspectPart, page, pageSize, subprojectName, status) {
  console.log(`这是请求过来的数据${inspectPart}  ${page}    ${pageSize}  ${subprojectName}, ${status}`)
  return request({
    url: `/statementManage/getInspectCheck?inspectPart=${inspectPart}&page=${page}&pageSize=${pageSize}&subprojectName=${subprojectName}&status=${status}`,
    method: 'get'
  })
}

export function searchInpsectCheckPreview(taskId) {
  console.log(`taskId${taskId}正在生成报表`)
  return request({
    url: `/statementManage/getInspectCheckItems?taskId=${taskId}`,
    method: 'get'
  })
}

export function searchOriginalInpsectCheckPreview(taskId) {
  console.log(`taskId${taskId}正在生成检验批原始记录报表`)
  return request({
    url: `/statementManage/getOriginalInspectCheckPreview?taskId=${taskId}`,
    method: 'get'
  })
}

export function exportInspectCheckPreview(taskId) {
  console.log(`正在导出检验批验收记录报表`)
  return request({
    url: `/statementManage/exportInspectCheck?taskId=${taskId}`,
    responseType: 'blob',
    method: 'get'
  })
}

export function batchExportInpsectCheckPreview(taskIds) {
  console.log(`批量导出检验批验收记录报表`)
  return request({
    url: '/statementManage/batchExportInspectCheck',
    data: taskIds,
    responseType: 'blob',
    method: 'post'
  })
}

export function exportOriginalInpsectCheckPreview(taskId) {
  console.log(`正在导出检验批原始验收记录报表`)
  return request({
    url: `/statementManage/exportOriginalInspectCheck?taskId=${taskId}`,
    method: 'get',
    responseType: 'blob'
  })
}

// 导出检验批原始记录（使用新接口）
export function exportOriginalInspectCheckByTemplate(taskId) {
  return request({
    url: `/statementManage/exportOriginalInspectCheckByTemplate?taskId=${taskId}`,
    method: 'get',
    responseType: 'blob'
  })
}

export function batchExportOriginalInpsectCheckPreview(taskIds) {
  console.log(`批量导出检验批原始记录报表`)
  return request({
    url: '/statementManage/batchExportOriginalInspectCheck',
    data: taskIds,
    responseType: 'blob',
    method: 'post'
  })
}

export function searchFenxiangCheck(projectName, subprojectName, fenxiangName, currentPage, pageSize) {
  return request({
    url: `/statementManage/getFenxiangCheck?projectName=${projectName}&subprojectName=${subprojectName}&fenxiangName=${fenxiangName}&page=${currentPage}&pageSize=${pageSize}`,
    method: 'get'
  })
}

export function searchFenxiangCheckPreview(subprojectId, fenxiangId) {
  console.log(`subprojectId${subprojectId}  fenxiangId:${fenxiangId}`)
  return request({
    url: `/statementManage/getFenxiangCheckPreview?subprojectId=${subprojectId}&fenxiangId=${fenxiangId}`,
    method: 'get'
  })
}

export function searchFenbuCheck(projectName, subprojectName, fenbuName, currentPage, pageSize) {
  return request({
    url: `/statementManage/getFenbuCheck?projectName=${projectName}&subprojectName=${subprojectName}&fenbuName=${fenbuName}&page=${currentPage}&pageSize=${pageSize}`,
    method: 'get'
  })
}

export function searchFenbuCheckPreview(subprojectId, fenbuId) {
  return request({
    url: `/statementManage/getFenbuCheckPreview?subprojectId=${subprojectId}&fenbuId=${fenbuId}`,
    method: 'get'
  })
}

//隐蔽验收记录列表
export function searchYinbi(current, size, inspectPart, subprojectName, projectName) {
  return request({
    url: `/statementManage/getYinBiItems?page=${current}&pageSize=${size}&inspectPart=${inspectPart}&subprojectName=${subprojectName}&projectName=${projectName}`,
    method: 'get'
  })
}

//隐蔽验收记录详情
export function searchYinbiItem(taskId) {
  return request({
    url: `/statementManage/getYinBiItem?taskId=${taskId}`,
    method: 'get'
  })
}

//见证取样记录
export function searchSamplingRecord(page, pageSize, subprojectName, witnessDate) {
  return request({
    url: `/statementManage/getSamplingRecord?witnessDate=${witnessDate}&subprojectName=${subprojectName}&page=${page}&pageSize=${pageSize}`,
    method: 'get'
  })
}

//报审表
export function submitForApproval(page, pageSize, subprojectName, usePart, fetchDate) {
  return request({
    url: `/statementManage/submitForApproval?fetchDate=${fetchDate}&usePart=${usePart}&subprojectName=${subprojectName}&page=${page}&pageSize=${pageSize}`,
    method: 'get'
  })
}

// 导出分部验收记录
export function exportFenbuCheckByTemplate(subprojectId, fenbuId) {
  return request({
    url: `/statementManage/exportFenbuCheckByTemplate?subprojectId=${subprojectId}&fenbuId=${fenbuId}`,
    method: 'get',
    responseType: 'blob'
  })
}

// 导出分项验收记录
export function exportFenxiangCheckByTemplate(subprojectId, fenxiangId) {
  return request({
    url: `/statementManage/exportFenxiangCheckByTemplate?subprojectId=${subprojectId}&fenxiangId=${fenxiangId}`,
    method: 'get',
    responseType: 'blob'
  })
}

// 导出钢筋原材见证记录
export function exportRebarWitnessRecordByTemplate(dataId) {
  return request({
    url: `/statementManage/exportRebarWitnessRecordByTemplate?dataId=${dataId}`,
    method: 'get',
    responseType: 'blob'
  })
}
